package com.woniu.ly.ticketassembly.rabbitMQ;

import org.springframework.amqp.core.AcknowledgeMode;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {

    @Autowired
    private CachingConnectionFactory cachingConnectionFactory;

    @Bean
    public SimpleMessageListenerContainer simpleMessageListenerContainer(){
        SimpleMessageListenerContainer c = new SimpleMessageListenerContainer();
        c.setAcknowledgeMode(AcknowledgeMode.AUTO);
        c.setConnectionFactory(cachingConnectionFactory);
        c.setPrefetchCount(1);
        c.setConcurrentConsumers(1);
        return c;
    }

}
